package com.wa.annotations.conditions;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Conditional;
import org.springframework.context.annotation.Configuration;


@Configuration
public class ConditionConfig {


    /**
     * @Conditional({Condition}) ： 按照一定的条件进行判断，满足条件给容器中注册bean
     * <p>
     * 如果系统是windows，给容器中注册("windows")
     * 如果是linux系统，给容器中注册("linus")
     */
    @Conditional({WindowsCondition.class})
    @Bean("windows")
    public Person person01() {
        return new Person("windows", 62, "1");
    }

    @Conditional(LinuxCondition.class)
    @Bean("linus")
    public Person person02() {
        return new Person("linus", 48, "2");
    }
}